package com.scpii.api.common.auth.token;

import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class HeaderRquestToken implements RequestToken {

	private final static Log logger = LogFactory
			.getLog(DefaultRequestToken.class);

	@Override
	public String getRequestToken(HttpServletRequest request) {
		logger.debug("Trying request parameters.");
		@SuppressWarnings("unchecked")
		Enumeration<String> headers = request.getHeaders("Authorization");
		while (headers.hasMoreElements()) {
			String value = headers.nextElement();
			return value;
		}
		return null;
	}

}
